﻿
@{
    ViewBag.Title = "扫描二维码";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@*<ol class="breadcrumb">
    <li><span class="glyphicon glyphicon-home"></span>  @Html.ActionLink("首页", "Index", "Home")</li>
    <li>@Html.ActionLink("扫描", "Index", "Scan")</li>
</ol>*@
@Html.Raw(ViewBag.Message)

<div class="container">
    <div class="row clearfix">
        @*<div class="col-md-4 column">*@
        </div>
        <div class="col-md-4 col-md-offset-4 column btn btn-lg btn-primary" node-type="qr-btn">
            <span class="glyphicon glyphicon-qrcode" style="position:absolute;top: 35%; right: 0; bottom: 50%; left: 0;"> 扫码</span>
            <input node-type="jsbridge" type="file" class="btn btn-large btn-block" style="opacity:0;display:inline-block;" value="扫描" />
        </div>
        @*<div class="col-md-4 column">
        </div>*@
    </div>
</div>
@section style{
    @Styles.Render("~/Content/bootstrapplugincss")
}


@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/bootstrapplugin")
    @Scripts.Render("~/bundles/qrcodeplugin")
    <script>
        function PostQRCode(data) {
            if (/error decoding QR Code/.test(data)) {
                BootstrapDialog.alert("不能识别该二维码！请再次尝试。");
                //alert("不能识别！");
            }
            else {
                $.post("/Scan/SaveQRCode", { emp: data }, function (data) {
                    BootstrapDialog.alert(data.Message);
                    //alert(data.Message);
                }, "json");
                //alert("扫描成功：" + data);
            }
        }
        //初始化扫描二维码按钮，传入自定义的 node-type 属性
        //$(document).ready()的简写,表示dom加载后执行，保证能找到元素。
        $(function () {
            //$('[node-type=qr-btn]').click($(this).addClass("btn-default"));
            //$('[node-type=qr-btn]').click(function () {
            //    $(this).addClass("btn-primary");
            //});
            Qrcode.init($('[node-type=qr-btn]'));
        });
    </script>
}